#coding=utf-8

import xlrd
import xlwt

def read_ts_content(xl_file_path):
    ts_info = {}
    
    wb = xlrd.open_workbook(xl_file_path)
    if(len(wb.sheet_names()) == 0):
        return ts_info

    sheet = wb.sheet_by_index(0)
    row_cnt = sheet.nrows
    for r in range(1, row_cnt):
        line = sheet.row_values(r)
        ts_info[line[0]] = line[1]

    return ts_info

def write_need2ts(lst_no_trans, xl_file_path):
    f = xlwt.Workbook()
    sheet = f.add_sheet('need2ts')
    header_names = ["中文", "英文"]
    for i in range(0, len(header_names)):
        sheet.write(0, i, header_names[i])

    for i in range(0, len(lst_no_trans)):
        sheet.write(i+1, 0, lst_no_trans[i])
    
    f.save(xl_file_path)